using System.Linq.Expressions;
using Chengheng.Entity.Commodity;
using Microsoft.EntityFrameworkCore;

namespace Chengheng.Entity;

public class ChenghengDbContext : DbContext
{
    public ChenghengDbContext()
    {
    }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseMySql("""
                                server=localhost;
                                port=3306;
                                user=root;
                                password=rootroot;
                                database=chengheng_test_efcore
                                """,
            ServerVersion.Parse("8.4.3-mysql"));
    }

    public virtual DbSet<Commodity.Commodity> Commodity { get; set; }

    public virtual DbSet<AuditEntry> AuditEntry{ get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
       
            
        modelBuilder.Entity<Commodity.Commodity>(entity =>
        {
            entity.HasKey(commodity => commodity.Id);

        });


    }

    public void Test(Expression<Func<string, string>> e)
    {

    }
}